//
// Created by konglinglong on 2020/9/11.
//

#ifndef O5G_SRC_O5GRAN_L1_INCLUDE_L1DEF_H
#define O5G_SRC_O5GRAN_L1_INCLUDE_L1DEF_H

#include "../../../../lib/csp/include/cspApi.h"
#include "../../include/ranApi.h"
#include "../../lcore/include/commDef.h"

#define RAN_L1_TTI_BUFF_NUM  8

typedef struct RanL1UeInst
{
    uint32_t inUse;
    uint32_t ueId;

    uint32_t nbIdx;
    uint32_t cellIdx;
    uint32_t ueIdx;

} S_RanL1UeInst;

typedef struct RanL1CellInst
{
    uint32_t inUse;
    uint32_t cellId;

    uint32_t nbIdx;
    uint32_t cellIdx;

    E_AppState appState;

    uint32_t sendTtiIntCount;
    uint32_t recvTtiReqCount;

    S_OsSelect ttiIntSelector;

    uint16_t dlSubcarrierSpacing;

    uint16_t sfn;
    uint16_t slot;
    uint16_t slotNum;

    S_VarRingBuffer *pL2L1CpMsgQue;
    S_VarRingBuffer *pL1L2CpMsgQue;
    S_VarRingBuffer *pL2L1UpMsgQue;
    S_VarRingBuffer *pL1L2UpMsgQue;

    S_VarRingBuffer *pUlTtiBuff[RAN_L1_TTI_BUFF_NUM];
    S_VarRingBuffer *pDlTtiBuff[RAN_L1_TTI_BUFF_NUM];

    S_VarRingBuffer *pRanUeQue;
    S_VarRingBuffer *pUeRanQue;

    uint32_t ueNum;
    S_RanL1UeInst ueInst[RAN_UE_NUM_MAX];
} S_RanL1CellInst;

typedef struct RanL1NbInst
{
    uint32_t inUse;
    uint32_t nbId;

    uint32_t nbIdx;

    uint32_t cellNum;
    S_RanL1CellInst cellInst[RAN_CELL_NUM_MAX];
} S_RanL1NbInst;

typedef struct RanL1Context
{
    pthread_t tid;

    uint32_t nbNum;
    S_RanL1NbInst nbInst[RAN_NODEB_NUM_MAX];
} S_RanL1Context;

extern S_RanL1Context *gpRanL1Context;

#endif //O5G_SRC_O5GRAN_L1_INCLUDE_L1DEF_H
